import sys

def output(word, freq):
    if word:
        print '%s\t%d' % (word, freq)

def main():
    '''
    output: words_all.txt
    (word, freq..) -> (word, sum-of-freq)
    '''
    prev_word = ''
    freq = 0
    for line in sys.stdin:
        line = line.strip()
        word, val = line.split()
        if word == prev_word:
            freq += int(val)
        else:
            output(prev_word, freq)
            prev_word = word
            freq = int(val)
    output(prev_word, freq)

if __name__ == '__main__':
    main()
